//        https://ac.nowcoder.com/acm/problem/219641





#include <iostream>
#include <queue>
using namespace std;

int ans[100005] = { 0 };

int main()
{
    int n, x;
    priority_queue<int> a;
    a.push(0);
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> x;
        a.push(x);
        x = a.top();
        a.pop();
        ans[i] = a.top();
        a.push(x);
    }
    int q;
    cin >> q;
    while (q--)
    {
        cin >> x;
        cout << ans[x] << endl;
    }
    return 0;
}